package com.heima.article.controller.v1;

import com.heima.article.service.ApArticleService;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.article.dtos.ArticleDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
public class ApArticleController {

    @Autowired
    private ApArticleService apArticleService;

    /*
        查询首页
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleDto articleDto){

        return apArticleService.loadApArticle(articleDto,1);
    }

    /*
        更多文章（上拉）
     */
    @PostMapping("/loadmore")
    public ResponseResult loadmore(@RequestBody ArticleDto articleDto){

        return apArticleService.loadApArticle(articleDto,1); // 1 代表小于判断
    }

    /*
        最新文章（下拉）
     */
    @PostMapping("/loadnew")
    public ResponseResult loadnew(@RequestBody ArticleDto articleDto){

        return apArticleService.loadApArticle(articleDto,2); // 2 代表大于判断
    }
}
